//  Inside Microsoft Exchange 2007 Web Services
//  Chapter 8
//
//  Copyright (c) 2007 David Sterling, Ben Spain, Mark Taylor, Huw Upshall, Michael Mainer.
//  All rights reserved.
//
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using ProxyHelpers.EWS;

namespace CreateCalendarItemWithMeetingTimeZone
{
    class Program
    {
        static void Main(string[] args)
        {
            // Note that this call only creates the local instance of the calendar item. It does not
            // make the CreateItem web method call to create the calendar item in the mailbox.
            //
            CalendarItemType calendarItem = CreateCalendarItemWithMeetingTimeZone();
        }

        /// <summary>
        /// Creates a calendar item with a meeting time zone (Listing 8-7)
        /// </summary>
        /// <returns>New Calendar Item</returns>
        /// 
        public static CalendarItemType CreateCalendarItemWithMeetingTimeZone()
        {
            // Create a new calendar item
            //
            CalendarItemType newCalendarItem = new CalendarItemType();
            newCalendarItem.MeetingTimeZone = new TimeZoneType();

            // We want to create a MeetingTimeZone for our new calendar item
            // representing a timezone bias of 5 hours, or Eastern Standard Time which
            // is defined as GMT-05:00
            //
            // We will use the TimeSpanToXSDuration method defined in the "Understanding
            // xs:duration sidebar of Chapter 8"
            //
            TimeSpan fiveHourOffset = new TimeSpan(5, 0, 0); // Hours, Minutes, Seconds
            newCalendarItem.MeetingTimeZone.BaseOffset =
                          DateTimeHelpers.TimeSpanToXSDuration(fiveHourOffset);
            return newCalendarItem;
        }

    }
}
